#ifndef VideoMeasureVelocity_h
#define VideoMeasureVelocity_h

#include "cv.h"
#include "iostream"
using namespace std;

#ifdef _USRDLL
#define DLL_API _declspec(dllexport)   
#else
#define DLL_API _declspec(dllimport) 
#endif  

struct kzTime
{
	int tv_sec; 
	int tv_usec; 
};

class  CVideoMeasureVelocity
{
public:
	void Init(float leftTopX,float leftTopY,float rightTopX,float rightTopY,
		float leftBottomX,float leftBottomY,float rightBottomX,float rightBottomY,
		float realWidth,float realHeight, float ratio=1.0f);

	int VideoMeasureVelocity(CvRect rectArr[], kzTime timeArr[], int arrCount);

private:
	void Calibration(float leftTopX,float leftTopY,float rightTopX,float rightTopY,
		float leftBottomX,float leftBottomY,float rightBottomX,float rightBottomY,
		float k,float realWidth,float realHeight,float pixX,
		float pixY,float &realX,float &realY);
		double CalcDistance(float startX, float startY, float endX, float endY);

private:
	float m_leftTopX;
	float m_leftTopY;
	float m_rightTopX;
	float m_rightTopY;
	float m_leftBottomX;
	float m_leftBottomY;
	float m_rightBottomX;
	float m_rightBottomY;

	float m_realWidth;
	float m_realHeight;
	float m_ratio;
};

CVideoMeasureVelocity vmv;

extern "C" {

	void DLL_API InitVelocietyMeasure(float leftTopX,float leftTopY,float rightTopX,float rightTopY,
		float leftBottomX,float leftBottomY,float rightBottomX,float rightBottomY,
		float realWidth,float realHeight, float ratio=1.0f);

	int DLL_API CalcVelociety1(int x1, int y1, int x2, int y2, int nanosecond);

	int DLL_API CalcVelociety2(CvRect rect[], kzTime tm[], int count);

};


#endif


